package com.wxy.JDK;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class MyProwy {
	public static void main(String[] args) {
		final userDao userDao=new userDaoImpl();
		final Advice advice=new Advice();
		userDao userDao2=(com.wxy.JDK.userDao) Proxy.newProxyInstance(
				userDao.getClass().getClassLoader(), 
				userDao.getClass().getInterfaces(),
				new InvocationHandler() {
			
			@Override
			public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
				// TODO 自动生成的方法存根
				advice.before();
				method.invoke(userDao, args);
				advice.after();
				return null;
			}
		});
		userDao2.addUser();
	}
}
